package hai.com.android_test.ui;

import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;

import java.util.ArrayList;
import java.util.List;

import butterknife.ButterKnife;
import hai.com.android_test.R;
import hai.com.android_test.adapter.MyAdapter;

//implements OnLoadMoreListener
public class MyRecycleViewActivity extends AppCompatActivity {

    private static final String TAG = "MainActivity";
    List<String> datas = new ArrayList<>();
    int intn = 5;
    MyAdapter adapter;
    //    @BindView(R.id.myrecycleView)
//    ExpandRecycleView myrecycleView;
    Handler handler = new Handler();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_myrecycleview);
        ButterKnife.bind(this);
        init();
    }

    private void init() {
        for (int i = 0; i < 12; i++) {
            datas.add("str" + i);
        }
//        myrecycleView.setAdapter(adapter = new MyAdapter(datas));
//        myrecycleView.setOnLoadMoreListener(this);
    }
//
//    @Override
//    public void onLoadMore() {
//        handler.postDelayed(new Runnable() {
//            @Override
//            public void run() {
//                int ran = new Random().nextInt(100);
//                final int itemCount = myrecycleView.getAdapter().getItemCount();
//                for (int i = 0; i < 7; i++) {
//                    datas.add(ran + "str" + i);
//                }
//
//                myrecycleView.getAdapter().notifyItemRangeInserted(itemCount - 1, 7);
//                if (intn == 4)
//                    myrecycleView.setLoadMoreCompleted();
//                else if (intn == 5)
//                    myrecycleView.setLoadNetWorkError();
//                else myrecycleView.setLoadNoMore();
//                Log.e(TAG, "run: int n=" + intn);
//                intn++;
//            }
//        }, 1500);
//
//    }
}
